// 防抖 触发事件后的一段时间内函数只执行一次，如果在一段时间内又触发了事件，则重新计时
export const debounce = (fn: Function, delay: number) => {
  let timer: ReturnType<typeof setTimeout> | undefined = undefined
  return (...args: any[]) => {
    if (timer) clearTimeout(timer)
    timer = setTimeout(() => {
      fn(...args)
    }, delay)
  }
}
